﻿function initialize() {
    var map;
    var marker;
    var _markers = new Array();
    var _stations;
    var coordInfoWindow;
    var options = {
        zoom: 13,
        center: new google.maps.LatLng(41.99997, 21.3983),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        navigationControl: true,
        streetViewControl: false,
        scaleControl: true
    };
    var _mapDiv = document.getElementById("map_canvas");
    map = new google.maps.Map(_mapDiv, options);
    google.maps.event.addListener(map, 'click', function (e) {
        marker = new google.maps.Marker({
            position: new google.maps.LatLng(e.latLng.lat(), e.latLng.lng()),
            map: map
        });
        google.maps.event.addListener(marker, 'rightclick', function (e) {
            e.preventDefault ? e.preventDefault() : e.returnValue = false;
            for (var i = 0; i < _markers.length; i++)
                if (_markers[i].getPosition() == e.latLng) {
                    _markers[i].setMap(null);
                    _markers.splice(i, 1);
                }
            _stations = "";
            for (i = 0; i < _markers.length; i++) {
                _stations += _markers[i].getPosition().lat().toFixed(6) + "," + _markers[i].getPosition().lng().toFixed(6) + ";";
            }
            document.getElementById('inputText').value = _stations;
        });
        _markers.push(marker);
        _stations = "";
        for (var i = 0; i < _markers.length; i++) {
            _stations += _markers[i].getPosition().lat().toFixed(6) + "," + _markers[i].getPosition().lng().toFixed(6) + ";";
        }
        document.getElementById('inputText').value = _stations;

    });
}